package com.mapmash.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.maps.client.InfoWindowContent;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.control.LargeMapControl;
import com.google.gwt.maps.client.geocode.DirectionQueryOptions;
import com.google.gwt.maps.client.geocode.Directions;
import com.google.gwt.maps.client.geocode.DirectionsCallback;
import com.google.gwt.maps.client.geom.LatLng;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class MapRacer implements EntryPoint {
  private MapWidget map;
  private DirectionsCallback callback = new DirectionsCallbackImpl();
  private DirectionQueryOptions options;
  
  /**
   * This is the entry point method.
   */
  public void onModuleLoad() {
	  options = new DirectionQueryOptions(map);
	  options.setRetrieveSteps(true);
	  
	  	// Open a map centered on Cawker City, KS USA
	    map = new MapWidget(new LatLng(39.509,-98.434), 2);
	    map.setSize("500px", "300px");
	    
	    // Add some controls for the zoom level
	    map.addControl(new LargeMapControl());
	    
	    // Add an info window to highlight a point of interest
	    map.getInfoWindow().open(map.getCenter(), 
	        new InfoWindowContent("World's Largest Ball of Twine"));

	    // Add the map to the HTML host page
	    RootPanel.get("map").add(map);
		  
	  	Directions.load("from: Seattle to: San Francisco", options, callback);
	    
  }
}
